es5_JSON
let str = '[{"name":"大胖","age":23},{"name":"骚胖","age":24}]';
let arr = [
{"name":"大胖","age":23},
{"name":"骚胖","age":24}
];
用来将json字符串转成json对象(json的反序列化):
let jsonObj = JSON.parse(str);
console.log(jsonObj);//打印出[Object, Object]
用来将json对象转成json字符串(json的序列化):
let jsonStr = JSON.stringify(arr);
console.log(jsonStr);//打印出[{"name":"大胖","age":23},{"name":"骚胖","age":24}]
String trim:
let str5 = ' abc';
console.log("|"+str5+"|");//打印出| abc|
console.log("|"+str5.trim()+"|");//打印出|abc|
正则:
let reg = /^(\s+)|(\s+)$/g;
console.log("|"+str5.replace(reg,'')+"|");//打印出|abc|
Date:
console.log(Date.now());//打印出1500706861909
console.log(new Date().toJSON());//打印出2017-07-22T07:01:01.909Z
console.log(new Date().toISOString().slice(0,10));//打印出2017-07-22
Number:
let a = new Number(1.326);
let b = new Number(1.324);
console.log(a.toFixed(2));//打印出1.33
console.log(b.toFixed(2));//打印出1.32
let c = 10000000000000;
console.log(c.toPrecision(4));//打印出1.000e+13
console.log(Math.round(12.34));//打印出12
function call apply:
var x = 1;
let obj5 = {
x:2
}
function fn1(a,b){
console.log(this.x);
}
fn1();
let fn2 = fn1.bind(obj5);
fn2();
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。